<html>
<head>
    <meta charset="utf-8">
    <title>会员卡</title>
    {php include $this->template($this->cur_tpl.'/_common_meta');}
    <link rel="stylesheet" type="text/css" href="{RES}mobile/{php echo $this->cur_tpl}/css/main.css" media="all">
    <link rel="stylesheet" type="text/css" href="{RES}mobile/{php echo $this->cur_tpl}/css/dialog.css" media="all">
    <link rel="stylesheet" type="text/css" href="{RES}mobile/{php echo $this->cur_tpl}/css/font-awesome.css" media="all" />
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/jquery_min.js"></script>
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/dialog_min.js"></script>
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/mymain.js"></script>
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/dater_min.js"></script>
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/main.js"></script>
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/aSelect.js"></script>
    <script type="text/javascript" src="{RES}mobile/{php echo $this->cur_tpl}/js/aLocation.js"></script>
</head>
<body onselectstart="return true;" ondragstart="return false;" style="">
<script>
    $().ready(function(){
        <!-- 系统字段生日是否必填-->
    });
    function bd(){
        var d = new iDialog();
        var html = '<ul class="list_ul_card">\
				<form id="form2" action="javascript:;" method="post">\
				<input name="fromurl" value="" type="hidden"/>\
					<li data-card>\
						<table>\
						    <tr class="input wrapInput">\
								<td>\
									<label class="pre" style="color:#333333;"> 实体卡卡号：</label> \
								</td>\
								<td style="width:100%;">\
									<input type="text" name="entry_cardno" placeholder="请输入实体卡卡号" maxlength="15" class="input" />\
								</td>\
							</tr>\
							<tr class="input wrapInput">\
								<td>\
									<label class="pre" style="color:#333333;"> 实体卡手机号：</label> \
								</td>\
								<td style="width:100%;">\
									<input type="tel" name="entry_mobile" placeholder="请输入手机号码" maxlength="15" class="input" />\
								</td>\
							</tr>\
						</table>\
					</li>\
				</form>\
			</ul>';
        d.open({
            classList: "valid_phone bd",
            title:"",
            close:"",
            content:html,
            btns:[
                {id:"", name:"确定", onclick:"fn.call();", fn: function(self){
                    //alert("queding");
                    submit2();
                }},
                {id:"", name:"取消", onclick:"fn.call();", fn: function(self){
                    self.die();
                }}
            ]
        });
    }

    function submit2(){
        var form = document.getElementById("form2");
        loading(true);
        var url = "{php echo $this->createMobileUrl('GetOldCard', array(), true);}"
        $.ajax({
            url: url,
            type:"POST",
            data:$("#form2").serialize(),
            dataType:"json",
            success: function(data){
                loading(false);
                if (data.status  == 0) {
                    alert(data.message, 1500);
                    url = "{php echo $this->createMobileUrl('index', array(), true)}";
                    setTimeout("location.href='" + url + "'", 1500);
                } else {
                    alert(data.message, 1500);
                }
            }
        });
    }

    function submit1(){
        var form = document.getElementById("form1");
        var obj = {
            username: form.username.value,
            mobile: form.mobile.value
            //validCode: form.validCode.value
        }

        if(obj.username.length<2){
            alert("请输入姓名,不少于2个字符", 1500);
            return;
        }

        if(obj.mobile.length==0){
            alert("请输入正确的手机号", 1500);
            return;
        }

        var url = "{php echo $this->createMobileUrl('getnewcard', array(), true);}"
        loading(true);
        $.ajax({
            url: url,
            type:"POST",
            data:$("#form1").serialize(),
            dataType:"json",
            success: function(data){
                loading(false);
                if (data.status  == 0) {
                    alert(data.message, 1500);
                    url = "{php echo $this->createMobileUrl('index', array(), true)}";
                    setTimeout("location.href='" + url + "'", 1500);
                } else {
                    alert(data.message, 1500);
                }
            }
        });

    }
</script>
<div class="container info_tx">
    <div class="body pt_10">
        <ul class="list_ul_card">
            <form id="form1" action="javascript:;" method="post">
                <input name="fromurl" value="{$fromurl}" type="hidden">
                <li data-card="">
                    <header class="center">
                        <label style="display:inline-block;">填写会员卡资料</label>
                    </header>
                    <h5>必填信息</h5>
                    <div class="forms">
                        <dl>
                            <dt>姓 名： </dt>
                            <dd><input type="text" name="username" placeholder="请输入姓名" maxlength="30" class="input" value="{$fans['realname']}"></dd>
                        </dl>
                        
                         <!--&lt;!&ndash; 系统字段生日是否必填&ndash;&gt;-->
                        <dl>
                          <dt>生 日：</dt>
                           <dd>
                              <input type="date" name="birth" placeholder="生 日" maxlength="30" class="input" value="{$fans['birth']}"> 
                            </dd>
                        </dl>
                        
                        <dl>
                            <dt>手 机：</dt>
                            <dd><input type="tel" name="mobile" placeholder="请输入手机号码" maxlength="30" class="input" value="{$fans['mobile']}"></dd>
                        </dl>
                       
                       <dl class="vecobut">
                            <dt>验证码： </dt>
                            <dd>
                                <input type="text" name="smscode" placeholder="请输入验证码" maxlength="30" class="input" value="">
                                <input type="button" class="btn" value="获取验证码" onclick="getReceiveMemberCardVCode(this,'form1','mobile');" time="0" id="dosendbtn">
                            </dd>
                        </dl>

                       
                    </div>
                </li>
                <ul class="add_op">
                    <li style="padding:10px 0 0;">
                        <a href="javascript:submit1();" style="width:100%;">提&nbsp;&nbsp;&nbsp;交</a>
                    </li>
                   
                </ul>
            </form>
        </ul>
    </div>
</div>
<script type="text/javascript">
    var intervalId,buttonObj;
    //发送下一条短信需要间隔的秒数
    var seconds = 60;
    
    function getReceiveMemberCardVCode(clickObj,formId,teleName){
      //  var pid = 18692;
        var form = document.getElementById(formId);
        var req = {
            mobile: $.trim(form[teleName].value),
           // pid:pid,
          //  ch_type:ch_type
        }
        if(!req.mobile){
            alert("请输入手机号", 1000);return;
        }
        
        clickObj.setAttribute("disabled", "disabled");
        clickObj.value = "正在发送，请稍候...";
      //  return false; {php echo $this->createMobileUrl('getnewcard', array(), true);} SendPhoneCheckCode
        $.ajax({
            url: "{php echo $this->createMobileUrl('SendPhoneCheckCode', array(), true);}",
            type:"post",
            data:req,
            dataType:"JSON",
            success: function(res){
                if('Success' == res.returnstatus){
                    clickObj.value = '验证码发送成功';
                    buttonObj = clickObj;
                    intervalId = setInterval("ticker()",1000);
                }else{
                    alert(res.message,1500);
                    return false;
                }
            }
        });
    }
    function ticker(){
        seconds --;
        if(seconds > 55){
            //提示消息显示5秒钟
        }else if(seconds>0){
            buttonObj.value = seconds+"秒后可重新获取";
        }else{
            clearInterval(intervalId);
            buttonObj.removeAttribute("disabled");
            buttonObj.value = "获取验证码";
            seconds = 60;
            buttonObj = null;
        }
    }
</script>
</body>
</html>